package com.xuzm.netty.operator.event;

import io.netty.channel.ChannelHandlerContext;
import lombok.Getter;
import org.springframework.context.ApplicationEvent;

/**
 * netty消息接收的事件
 */
@Getter
public class NettyMsgCustomEvent extends ApplicationEvent {
    /**接收到的消息*/
    private String message;
    public NettyMsgCustomEvent(ChannelHandlerContext source, String message) {
        super(source);
        this.message = message;
    }

    /**
     * 获取ctx对象，可获取地址等其他信息 或操作客服端的连接等
     */
    public ChannelHandlerContext getCtx() {
        return (ChannelHandlerContext)super.source;
    }
}
